<template>
	<div class="login_log_container" v-loading="flag">
		<cassotable :colList="colList" :tablelist="tablelist" :opt="true"></cassotable>
	</div>
</template>


<script>
import cassotable from "../../common/casso_table.vue";
export default {
	components: {
		cassotable,
	},
	data() {
		return {
			colList: [
				{ props: "usr_str", label: "登录用户" },
				{ props: "remote_addr", label: "登录IP" },
				{ props: "ace_time", label: "登录时间" },
				{ props: "status", label: "登录状态" },
				{ props: "agent", label: "客户端" },
				{ props: "os", label: "操作系统" },
			],
            tablelist: [],
            flag:true
		};
	},
	methods: {
		get_log_list() {
			this.$ajax.get("/loginlog").then((res) => {
                console.log(res);
				res.data.forEach((item) => {
                    item.ace_time = this.timeFomat(item.ace_time);
                    if(item.status){
                        item.status = "登录成功"
                    }else{
                        item.status = "登录异常"
                    }
                    item.agent = item.agent.split("/")[0]
				});
                this.tablelist = res.data;
                this.flag = false;
			});
		},
		timeFomat(val) {
			if (val) {
				let d = new Date(val);
				let yy = d.getFullYear();
				let mm = (d.getMonth() + 1).toString().padStart(2, "0");
				let dd = d.getDate().toString().padStart(2, "0");
				let hh = d.getHours().toString().padStart(2, "0");
				let mms = d.getMinutes().toString().padStart(2, "0");
				let ss = d.getSeconds().toString().padStart(2, "0");
				return `${yy}-${mm}-${dd} ${hh}:${mms}:${ss}`;
			} else {
				return val;
			}
		},
	},
	mounted() {
		this.get_log_list();
	},
};
</script>


<style lang="scss" scoped>
.login_log_container {
}
</style>